<template name="allGoodsAre">
	<view class="allGoodsAre">
		<view class="display column titleAre">
			<view class="display flow calc">
				<view class="display titleItemAre" :style="{'margin-bottom': isFilter?'0':'20rpx'}">
					<text>{{isFilter?'推荐商品':'全部商品'}}</text>
					<text class="pColor subTitle">全部超值商品，为你推荐</text>
				</view>
				<view class="display flow moreAre" v-if="isFilter" @click="moreBtn">
					<text>更多</text>
					<image src="/static/images/icon/more.png"></image>
				</view>
			</view>
			<goodsFilter @sortChanged="goodsFilterChanged" @defaultBtn="defaultBtn" v-if="isFilter"></goodsFilter>
		</view>
		<view class="display flow goodsAre">
			<view v-for="item in goodsList" :key="item.id">
				<view class="display column goodsItemAre borderR" v-bind:id="item.id" @click="goodsClick">
					<view class="imgAre">
						<image :src="item.head_img"></image>
						<view class="earnings" v-if="!isIntegral && Number(item.one_fx_price)">
							<text>分享收益 {{item.one_fx_price}} 元</text>
						</view>
					</view>
					<view class="display column goodsItem" v-if="isIntegral">
						<text class="goodsName fontHide2">{{item.product_name}}</text>
						<text class="price">{{item.integral}}积分</text>
					</view>
					<view class="display column goodsItem" v-else>
						<text class="goodsName fontHide">{{item.product_name}}</text>
						
						<view class="display flow priceAre" style="margin: 20rpx 0 0;">
							<text class="price">￥{{item.price}}</text>
							<text class="pColor" v-if="item.old_price && item.old_price > item.price">￥{{item.old_price}}</text>
						</view>
						<!-- <text class="pColor">销量：{{item.buy_num?item.buy_num:0}}</text> -->
					</view>
				</view>
			</view>
		</view>
		<loadMore ref="loadMore" @loadMoreListener='loadMoreListener' @clickLoadMore="clickLoadMore"></loadMore>
	</view>
</template>
 
<script>
	import util from '../common/util.js'
	import goodsFilter from '@/components/goodsFilter.vue'
	import loadMore from './loadMore.vue'
	export default {
		name: "allGoodsAre",
		components:{goodsFilter,loadMore},
		props: ['goodsList','isFilter','isIntegral'],
		data(){
			return {
				
			}
		},
		methods:{
			goodsClick(e){
				var id = e.currentTarget.id
				this.$emit('goodsClick',id)
			},
			defaultBtn(){
				this.$emit('filterChange',5)
			},
			goodsFilterChanged(filter){
				// console.log(filter)
				let sortType = 5
				if(filter.sort == 1){
					filter.order == 1?sortType = 2:sortType = 1
				}else if(filter.sort == 2){
					filter.order == 1?sortType = 4:sortType = 3
				}
				this.$emit('filterChange',sortType)
				// this.getData()
			},
			loadMoreListener(){
				this.$emit('loadMoreListener')
			},
			clickLoadMore(){
				this.$emit('clickLoadMore')
			},
			moreBtn(){
				uni.navigateTo({
					url: '/subPackages/goods/goodsAre/goodsAre?isAllGoods=' + true
				})
			},
		},
		
	}
</script>

<style scoped lang="scss">
	@import '@/common/css/goodsAre.scss';
	.allGoodsAre{
		@include width;
		@include margin(30rpx,'top');
	}
	.titleAre{
		box-shadow: 0rpx 5rpx 10rpx 0px rgba( 0, 0, 0, 0.1);
		@include width;
		@include backG;
		.titleItemAre{
			@include font($fontSize + 6rpx);
			@include margin(20rpx,'top');
			flex-flow: row nowrap;
			align-items: flex-end;
			font-weight: bold;
			.subTitle{
				@include margin(20rpx,'left');
				font-weight: normal;
			}
		}
		.moreAre{
			@include justify-content('s');
			@include font($fontSize - 2rpx);
			&>image{
				@include widthHeight(18rpx);
				@include margin(10rpx,'left');
			}
		}
	}
	.goodsItem{
		@include width;
		.goodsName{
			max-height: 70rpx;
		}
	}
	
</style>
